<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<%@ page import="com.scalar.chiptrack.commons.Constants" %>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>

<chiptrack:checkLogon sourcePage="/inventoryOutTrans.do?action=programOutsearch"/>
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();
    String userTypeChiptrac = Constants.USER_TYPE_CHIPTRAC + "";
%>

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel="stylesheet">
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/quickSearch.js"></script>
<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<script language="javascript">
var listSize = 0;
window.onload = init;
function init()
{
    if ( document.inventoryTransitform.processStepId  != null)
    {
        qs_1 = new QuickSearch(document.inventoryTransitform.processStepId, document.inventoryTransitform.qs1, false);
    }
    if ( document.inventoryTransitform.lotId  != null)
    {
        qs_2 = new QuickSearch(document.inventoryTransitform.lotId, document.inventoryTransitform.qs2, false);
    }
}

function reset()
{
    document.inventoryTransitform.reset();
    qs_1.resetQuickSearchCntrl();
    qs_2.resetQuickSearchCntrl();
}

function searchLots()
{
    var form = document.inventoryTransitform;
    var pa=document.getElementById("message");
    pa.innerHTML                = '';

    if ( form.processStepId.value == "0" )
    {
        pa.innerHTML = "<li> Please select Part number";
        form.processStepId.focus();
        return;
    }
    form.action.value="programOutlotNumbers";
    form.submit();
}
function quickSearchPart()
{
    if ( window.event.keyCode == 13 )
    {
        searchLots();
    }
}
/*function searchLotsOnSubmit()
{
    *//*var form = document.inventoryTransitform;
    form.action.value="programOutlotNumbers";
    form.submit();*//*
    searchLots();
}*/

function save()
{
    var pa=document.getElementById("message");
    pa.innerHTML                = '';

    var form                    = document.inventoryTransitform;
    var count1                  = 0;

    for( var i=0; i < listSize; i++ )
    {
        if( form['wipLotsList['+i+'].checked'].checked == true  )
        {
            var shipQty=0;
            var scrapQty=0;

           if ( form['wipLotsList['+i+'].nextLocation'].value == '-1')
           {
                pa.innerHTML = "<li> Please select Ship To Vendor locations";
                form['wipLotsList['+i+'].nextLocation'].focus();
                return;
           }
           else if ( form['wipLotsList['+i+'].toProcessStepId'].value == '-1')
           {
                pa.innerHTML = "<li> Please select receive Part number";
                form['wipLotsList['+i+'].toProcessStepId'].focus();
                return;
           }

           if ( form['wipLotsList['+i+'].shipDieQty'] != null )
           {
                if ( isNaN( parseInt( form['wipLotsList['+i+'].shipDieQty'].value ) ) )
                {
                     shipQty = 0;
                     form['wipLotsList['+i+'].shipDieQty'].value = shipQty;
                }
                else
                {
                      shipQty =  parseInt( form['wipLotsList['+i+'].shipDieQty'].value );
                }
            }
            else
            {
                 shipQty = 0;
                 form['wipLotsList['+i+'].shipDieQty'].value = shipQty;
            }

            if ( form['wipLotsList['+i+'].scrapDieQty'] != null )
           {
                if ( isNaN( parseInt( form['wipLotsList['+i+'].scrapDieQty'].value ) ) )
                {
                     scrapQty = 0;
                     form['wipLotsList['+i+'].scrapDieQty'].value = scrapQty;
                }
                else
                {
                      scrapQty =  parseInt( form['wipLotsList['+i+'].scrapDieQty'].value );
                }
            }
            else
            {
                 scrapQty = 0;
                 form['wipLotsList['+i+'].scrapDieQty'].value = scrapQty;
            }

            if( ( (+shipQty)+(+scrapQty) ) == 0 )
            {
                pa.innerHTML = "<li> Zero Qty was not allowed:";
                form['wipLotsList['+i+'].shipDieQty'].focus();
                return;
            }
            else if ( ( (+shipQty)+(+scrapQty) ) > parseInt(form['wipLotsList['+i+'].dieQtyIn'].value)  )
            {
                pa.innerHTML = "<li> Ship Qty should not be greater than available Qty ( <font color='blue'>" + parseInt(form['wipLotsList['+i+'].dieQtyIn'].value) + "</font> )";
                form['wipLotsList['+i+'].shipDieQty'].focus();
                return;
            }

            //form['wipLotsList['+i+'].remainQty'].disabled = false;
            
            count1++;
        }
    }

    if( count1==0 )
	{
		pa.innerHTML = "<li> Please select atleast one lot";
		return;
	}

    form.action.value = "programOutsave";
    form.submit();
}

function enableDieQtyOutField( index )
{
    var pa=document.getElementById("message");

    pa.innerHTML                = '';
    var form                    = document.inventoryTransitform;

    if(form['wipLotsList['+index+'].checked'].checked == true )
    {
        form['wipLotsList['+index+'].shipDieQty'].disabled = false;
        form['wipLotsList['+index+'].scrapDieQty'].disabled = false;
        form['wipLotsList['+index+'].shipDieQty'].focus();
    }
    else
    {
        form['wipLotsList['+index+'].shipDieQty'].value = parseInt(form['wipLotsList['+index+'].dieQtyIn'].value);
        form['wipLotsList['+index+'].scrapDieQty'].value = parseInt(form['wipLotsList['+index+'].dieQtyIn'].value) - parseInt(form['wipLotsList['+index+'].shipDieQty'].value) ;
        form['wipLotsList['+index+'].shipDieQty'].disabled = true;
        form['wipLotsList['+index+'].scrapDieQty'].disabled = true;
    }
}

function checkLength(element, size)
{
    if(	element.value.length >= size )
	{
		event.returnValue = false;
	}
}

</script>
<!-- Top Header Start-->
<%--<%@ include file="/jsp/includes/header.jsp" %>--%>
<logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/includes/header.jsp" %>
    </logic:equal>
    <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/includes/extHeader.jsp" %>
    </logic:notEqual>
<!-- Top Header End-->
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
	<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
<!-- Side Navigation start -->
<%--<%@ include file="/jsp/operations/dataentryMenu.jsp" %>--%>
    <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/operations/dataentryMenu.jsp" %>
    </logic:equal>
    <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/operations/ext_user_dataentryMenu.jsp" %>
    </logic:notEqual>
<!-- end of the side navigations -->
<TD bgcolor="#ffffff">
<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">
<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>
<html:form name="inventoryTransitform" method = "POST" type="com.scalar.chiptrack.operations.dataentry.inventoryTransit.forms.InventoryTransitForm" action="/inventoryOutTrans.do" >
<input type="hidden" name="action" value="<%= (String)request.getAttribute("action")%>">
<TABLE border="0" width="100%" align=center>
<TR><TD colspan=5 class="NArialW" align="center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Program Out</TD><TD width="25%" class="NArialL">&nbsp;</TD></TR>
<TR><TD colspan=6>&nbsp;</TD></TR>
<TR><TD width="10%" class="NArialL">&nbsp;</TD><TD colspan=5 class='NArialL'><strong><FONT id="message" styleClass="NArialL" color='FF0000'></FONT></strong></TD></TR>
<TR>
    <TD width="10%" class="NArialL">&nbsp;</TD>
    <TD colspan=4>
  <chiptrack:info styleClass="NArialL" />
  <chiptrack:errors styleClass="NArialL" />
  <chiptrack:messages type="info" styleClass="NArialL" />
</TD>
    <TD width="25%" class="NArialL">&nbsp;</TD>
</TR>
<logic:equal name="showMessage" value="TRUE">
    <tr><td colspan=6 align='left'><font class='NArialS'color='blue'><b><%=Constants.NO_MODIFY_RIGHTS %></b></font></TD></TR>
</logic:equal>
<TR>

<TD align="center" colspan=6>
<TABLE  border="0"  width="80%" cellpadding="1" cellspacing="1">
   
    <logic:present name="partNumbersList" >
    <TR>
        <TD width="10%" class="NArialL">&nbsp;</TD>
        <TD class="NArialL" width='20%'>Quick Search:</TD>
        <td class="NArialL" width='20%'>
        <input type="text" name="qs1" class="txfield" size='30' onkeyup='quickSearch(qs_1);quickSearchPart();'/>
        </td>
        <TD COLSPAN=3>&nbsp;</TD>
    </TR>
    </logic:present>

    <TR>
        <logic:present name="partNumbersList">
            <TD width="10%" class="NArialL">&nbsp;</TD>
            <TD width="20%" class="NArialL">Product Name: <font color="red"> * </font></TD>
            <TD width="20%" class="NArialL">
                <html:select property="processStepId" name="inventoryTransitform" styleClass="txfield">
                <html:option value="0">Select Part Number</html:option>
                <html:options collection="partNumbersList" property="value" labelProperty="label"/>
                </html:select>
            </TD>
        </logic:present>
        <logic:notPresent name="partNumbersList" scope="request">
            <TD width="10%" class="NArialL">&nbsp;</TD>
            <TD width="20%" class="NArialL">&nbsp;</TD>
            <TD width="20%" class="NArialL">&nbsp;</TD>
        </logic:notPresent>

        <logic:present name="locationList" scope="request">
            <TD align="center" width="15%"><font class="NArialL">Location:</font></TD>
            <TD align="left" width="15%" class="NArialL">
                <html:select property="locationId" name="inventoryTransitform" styleClass="txfield">
                    <html:options collection="locationList" property="value" labelProperty="label"/>
                </html:select>
            </TD>
            <TD width="20%" class="NArialL">&nbsp;</TD>
        </logic:present>
        <logic:notPresent name="locationList" scope="request">
            <TD width="15%" class="NArialL">&nbsp;</TD>
          <TD width="15%" class="NArialL">&nbsp;</TD>
          <TD width="20%" class="NArialL">&nbsp;</TD>
       </logic:notPresent>
   </TR>
    <TR>
        <TD colspan="6"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></TD>
    </TR>

    <logic:present name="lotsList" scope="request">
    <TR>
        <TD width="10%" class="NArialL">&nbsp;</TD>
        <TD class="NArialL" width='20%'>Quick Search:</TD>
        <td class="NArialL" width='20%'>
        <input type="text" name="qs2" class="txfield" size='23' onkeyup='quickSearch(qs_2)'/>
        </td>
        <TD COLSPAN=3>&nbsp;</TD>
    </TR>
    </logic:present>
    <TR>
        <logic:present name="lotsList" scope="request">
            <TD width="10%" class="NArialL">&nbsp;</TD>
            <TD width="20%" class="NArialL">Lot Number:</TD>
            <TD width="20%" class="NArialL">
                <html:select property="lotId" name="inventoryTransitform" styleClass="txfield">
                <html:option value="0">All Lot Numbers</html:option>
                <html:options collection="lotsList" property="lotId" labelProperty="lotNumber"/>
                </html:select>
            </TD>
        </logic:present>
        <logic:notPresent name="lotsList" scope="request">
            <TD width="10%" class="NArialL">&nbsp;</TD>
            <TD width="20%" class="NArialL">&nbsp;</TD>
            <TD width="20%" class="NArialL">&nbsp;</TD>
        </logic:notPresent>

        <TD width="15%" class="NArialL">&nbsp;</TD>
        <TD width="15%" class="NArialL">&nbsp;</TD>
        <TD width="20%" class="NArialL">&nbsp;</TD>
   </TR>

    <TR>
        <TD colspan="6"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></TD>
    </TR>
   <logic:present name="partNumbersList">
   <TR>
        <td colspan="6" align="center">
            <a href="javascript:searchLots()"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/search.gif" width="53" height="17" onmouseover="window.status='Click to Search for Inventory Out Lots';return true" onmouseout="window.status='';return true"title="Click to Search for Inventory Out Lots"/></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="javascript:reset();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17" onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"></a>
        </td>
    </TR>
    </logic:present>
    </TABLE>
   </TD>
 </TR>
</TABLE>
     <nested:present property="wipLotsList">
     <nested:size id="LotsSize" property="wipLotsList"/>
     <logic:greaterThan name="LotsSize" value="0">
     <!--<TR>
        <TD colspan="6" >-->
            <table width="100%" align="left" cellpadding="2" cellspacing="2" border="0">
                <tr>
                <td colspan="10"class='NArialL'><font class='NArialS'><font color='blue'>[Click on Select checkbox to Ship the Lots]</font></font></td>
            </tr>
            <tr bgcolor="#993333" align = "center">
                <td class='NArialL'><font color="#FFFFFF">Select </font></td>
                <td class='NArialL' nowrap><font color="#FFFFFF">Part Number</font></td>
                <td class='NArialL' nowrap><font color="#FFFFFF">Lot No#</font></td>
                <td class='NArialL'><font color="#FFFFFF">FabLot No#</font></td>
                <td class='NArialL'><font color="#FFFFFF">Vendor</font></td>
                <td class='NArialL'><font color="#FFFFFF">Date In</font></td>
                <td class='NArialL'nowrap><font color="#FFFFFF">Qty In</font></td>
                <td class='NArialL'><font color="#FFFFFF">Ship/Scrap Qty</font></td>
                <td class='NArialL'><font color="#FFFFFF">Receive Part#</font></td>
                <td class='NArialL'><font color="#FFFFFF">Ship To</font></td>
                <%--<td class='NArialL'><font color="#FFFFFF">Comments</font></td>--%>
           </tr>
            <nested:size id="listSize" property="wipLotsList"/>
            <nested:iterate id="wipInfo" property="wipLotsList" indexId="iterateIdx" type = "com.scalar.chiptrack.operations.dataentry.LotDetails">
             <% String click = "enableDieQtyOutField('" + iterateIdx.intValue() + "')"; %>

            <tr bgcolor='<%=iterateIdx.intValue() % 2 == 0 ? "#FFFFEE" : "#DEE1E2"%>'>
                <td align="center" class='NArialL'><nested:checkbox  name="wipInfo" property = "checked" onclick="<%= click %>"/></td>
                <td class='NArialL' nowrap><nested:write name="wipInfo" property ="partNumber"/></td>
                <td class='NArialL' nowrap><nested:write name="wipInfo" property ="lotNumber"/></td>
                <td class='NArialL'nowrap><nested:write name="wipInfo" property ="fabLotNumber"/></td>
                <td class='NArialL'><nested:write name="wipInfo" property ="vendorName"/></td>
                <td class='NArialL'><nested:write name="wipInfo" property ="dateIn"/></td>
                <td class='NArialL'nowrap><nested:write name="wipInfo" property ="dieQtyIn"/></td>
                <td class='NArialL' nowrap>

                    <nested:text name="wipInfo" property ="shipDieQty" styleClass="valuetxfield" size="8" disabled="true" onkeypress="javascript:allowInteger()"/>
                    <nested:text name="wipInfo" property ="scrapDieQty" styleClass="valuetxfield" size="8" onkeypress="javascript:allowInteger()" disabled="true"/>
                    <%--<nested:text name="wipInfo" property ="remainQty" styleClass="valuetxfield" size="8" disabled="true"/>--%>
                    <%--<nested:hidden name="wipInfo" property ="remainQty"/>--%>
                </td>
                <nested:hidden property="dieQtyIn"/>
                <nested:hidden property="processStepId"/>
                <nested:hidden property="locationId"/>
                <nested:hidden property="lotId"/>
                <td class='NArialL'>
                    <nested:select property="toProcessStepId" styleClass="txfield">
                        <html:option value="-1" >-- Select --</html:option>
                        <html:options collection="toPartNumbersList" property="value" labelProperty="label"/>
                    </nested:select>
                </td>
                <td class='NArialL'>
                    <nested:select property="nextLocation" styleClass="txfield">
                        <html:option value="-1" >-- Select --</html:option>
                        <html:options collection="nextLocations" property="label" labelProperty="label"/>
                    </nested:select>
                 </td>
                <%--<td><font class='NArialL'>
                   <nested:textarea name="wipInfo" property="comments" onkeypress="javascript:checkLength(this, 1000)" styleClass="txfield" rows="2" cols="20"/>
               </font>
               </td>--%>
            </tr>
             </nested:iterate>

           <script type="text/javascript">
               listSize = <%=listSize.intValue()%>;
           </script>
            <%--<tr bgcolor='#DEE1E2'>
                <td colspan="8" class='NArialL'><input type="checkbox" name="select_bottom" onClick = "javascript:setSelectAllIds(this)">&nbsp;&nbsp Select All</td>
            </tr>--%>
             <TR>
                <TD COLSPAN="10"><IMG SRC="<%=chipTracContext%>/jsp/includes/images/spacer.gif" HEIGHT=20></TD>
            </TR>
            <tr>
               <td align = "center" colspan ="10">
                    <a href="javascript:save()" onmouseover="window.status='Click here to Save the Transit Lots';return true" onmouseout="window.status='';return true" title="Click here to Save the Transit Lots"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="javascript:reset()" onmouseover="window.status='Click here to Reset the Transit Lots';return true" onmouseout="window.status='';return true" title="Click here to Reset the Transit Lots"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17"></a>
                </td>
            </tr>
              </table>
           <%-- </TD>
       </TR>--%>

    </logic:greaterThan>
    </nested:present>

</html:form>
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</BODY>
</HTML>

<%--<%
    }
    catch(Exception e )
    {
        e.printStackTrace();
    }
%>--%>
